<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>菜鸟hh</title>
</head>

<body>


<script>
{
    var p = new Object()
    p.fname = "kis"
    p.age = 33
    document.write(p.fname + " is " + p.age + " years old!<br>")
}

{
    var p = {
        fname: "mkioa",
        age: 55
    }
    document.write(p.fname + " is " + p.age + " years old!<br>")
}

{
    //使用函数来构造对象
    function persion(fname, age) {
        this.fname = fname
        this.age = age
        //this.uuid = "gj888"
    }
    //在一个已存在构造器的对象中是不能添加新的属性
    persion.uuid = "gt6"

    //也可以使用 prototype 属性就可以给对象的构造函数添加新的方法
    persion.prototype.name = function() {
        return this.fname
    }

    var p = new persion("rry8", 77)
    document.write(p.fname + " is " + p.age + " years old!<br>")

    //对象是可变的，它们是通过引用来传递的
    var p1 = p
    p.age += 1
    document.write(p.fname + " is " + p.age + " years old!<br>")
    document.write("p uuid:"+p.uuid+"<br>")

    //使用 prototype 属性就可以给对象的构造函数添加新的属性
    persion.prototype.uuid2 = "sloa789"
    document.write("p uuid2:"+p.uuid2+"<br>")

    document.write("p name:"+p.name()+"<br>")
}

</script>

</body>
</html>

